package org.looop.chuck.parser.impl;

import org.apache.commons.lang.StringUtils;
import org.looop.chuck.parser.HTMLParser;
import org.looop.chuck.parser.HTMLParserFactory;
import org.looop.chuck.persistence.PersistenceManager;
import org.looop.chuck.task.URLTaskManager;

public class DefaultHTMLParserFactory implements HTMLParserFactory {
	public HTMLParser createHTMLParser(String url, PersistenceManager persistenceManager, URLTaskManager urlTaskManager){
		if(StringUtils.contains(url, "wandoujia.apk.gfan.com/soft.aspx") || 
				StringUtils.contains(url, "wandoujia.apk.gfan.com/game.aspx")){
			return new WandoujiaListHTMLParser(persistenceManager, urlTaskManager);
		}
		if(HiApkListHTMLParser.matches(url)){
			return new HiApkListHTMLParser(persistenceManager, urlTaskManager, url);
		}
		if(ApkDetailHTMLParser.match(url)){
			return new ApkDetailHTMLParser(persistenceManager, urlTaskManager, url);
		}
		return null;
	}
}
